//
//  CommonModel.h
//  Youhu
//
//  Created by 王先森 on 2017/1/19.
//  Copyright © 2017年 ApeStar. All rights reserved.
//

#import "CommonModel.h"

@implementation CommonModel

/**
 *  类的属性 跟  服务端 json keypath 的映射
 *
 *  @return @{@"属性" :@"jsonKeyPath"}
 */
- (EnumModel *)chatModelWithCode:(NSString *)code{
    NSPredicate * predicate = [NSPredicate predicateWithFormat:@"SELF.code == %@",code];
    NSArray * result = [self.chat filteredArrayUsingPredicate:predicate];
    
    return [result firstObject];
}

- (BOOL)enableCustomerChargeMoney{
    EnumModel *enumModel= self.HAND_ENABLE.firstObject;
    if (!enumModel) {
        return NO;
    }
    return [enumModel.code isEqualToString:@"1"];
}

//- (EnumModel *)timeInterVal{
//    NSPredicate * predicate = [NSPredicate predicateWithFormat:@"SELF.label.intValue == %d",[[kGlobalData serviceDate] tx_hour]];
//    NSArray * filteredArray = [self.TIME_INTERVAL filteredArrayUsingPredicate:predicate];
//    EnumModel * model = [filteredArray firstObject];
//    return model;
//}

- (double)talent_deposit{
    EnumModel *enumModel= self.TALENT_DEPOSIT.firstObject;
    return enumModel.code.doubleValue;
}

- (NSString *)insTypeStringWithCodesArray:(NSArray<NSNumber *> *)insTypeCodes{
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(SELF.code in %@)", insTypeCodes];
    
    NSArray *predicateInsTypes = [self.INS_TYPE filteredArrayUsingPredicate:predicate];
    
    NSArray *names = [predicateInsTypes valueForKey:@"label"];
    
    return [names componentsJoinedByString:@","];
}

- (NSString *)weekDaysStringWithCodesArray:(NSArray<NSNumber *> *)weekdays{
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(SELF.code in %@)", weekdays];
    
    NSArray *predicateWeekDays = [self.week filteredArrayUsingPredicate:predicate];
    
    NSArray *names = [predicateWeekDays valueForKey:@"label"];
    
    return [names componentsJoinedByString:@","];
}

@end

@implementation EnumModel

@end
